﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace IRepository.Migrations
{
    public partial class _10 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Users");

            migrationBuilder.DropPrimaryKey(
                name: "PK_T_Roles",
                table: "T_Roles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_T_Members",
                table: "T_Members");

            migrationBuilder.DropPrimaryKey(
                name: "PK_T_MemberRoles",
                table: "T_MemberRoles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_T_MemberLevels",
                table: "T_MemberLevels");

            migrationBuilder.RenameTable(
                name: "T_Roles",
                newName: "Roles");

            migrationBuilder.RenameTable(
                name: "T_Members",
                newName: "Members");

            migrationBuilder.RenameTable(
                name: "T_MemberRoles",
                newName: "MemberRoles");

            migrationBuilder.RenameTable(
                name: "T_MemberLevels",
                newName: "MemberLevels");

            migrationBuilder.RenameColumn(
                name: "Id",
                table: "Members",
                newName: "Member_Id");

            migrationBuilder.RenameColumn(
                name: "Id",
                table: "MemberRoles",
                newName: "Member_Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Roles",
                table: "Roles",
                column: "Role_Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Members",
                table: "Members",
                column: "Member_Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_MemberRoles",
                table: "MemberRoles",
                column: "MemberRole_Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_MemberLevels",
                table: "MemberLevels",
                column: "MemberLevel_Id");

            migrationBuilder.CreateTable(
                name: "Permissions",
                columns: table => new
                {
                    Permission_Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Permission_Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Permission_RoutePath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Permission_RouteName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Permission_RouthFileName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Permission_RouteIcon = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Permission_ParentId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Permission_IsDeleted = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Permissions", x => x.Permission_Id);
                });

            migrationBuilder.CreateTable(
                name: "RolePermissions",
                columns: table => new
                {
                    RolePerssion_Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Role_Id = table.Column<int>(type: "int", nullable: false),
                    Permission_Id = table.Column<int>(type: "int", nullable: false),
                    RolePerssion_IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    RolePerssion_CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RolePermissions", x => x.RolePerssion_Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Permissions");

            migrationBuilder.DropTable(
                name: "RolePermissions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Roles",
                table: "Roles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Members",
                table: "Members");

            migrationBuilder.DropPrimaryKey(
                name: "PK_MemberRoles",
                table: "MemberRoles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_MemberLevels",
                table: "MemberLevels");

            migrationBuilder.RenameTable(
                name: "Roles",
                newName: "T_Roles");

            migrationBuilder.RenameTable(
                name: "Members",
                newName: "T_Members");

            migrationBuilder.RenameTable(
                name: "MemberRoles",
                newName: "T_MemberRoles");

            migrationBuilder.RenameTable(
                name: "MemberLevels",
                newName: "T_MemberLevels");

            migrationBuilder.RenameColumn(
                name: "Member_Id",
                table: "T_Members",
                newName: "Id");

            migrationBuilder.RenameColumn(
                name: "Member_Id",
                table: "T_MemberRoles",
                newName: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_T_Roles",
                table: "T_Roles",
                column: "Role_Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_T_Members",
                table: "T_Members",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_T_MemberRoles",
                table: "T_MemberRoles",
                column: "MemberRole_Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_T_MemberLevels",
                table: "T_MemberLevels",
                column: "MemberLevel_Id");

            migrationBuilder.CreateTable(
                name: "Users",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Pwd = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Users", x => x.Id);
                });
        }
    }
}
